package kg.aibek.projecteuler.p10;

public class Problem34 {
	private static int count = 0;
	private static int[] fact = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880 };

	public static void main(String[] args) {
		for (int i = 3; i < 100000000; i++) {
			if (i == factorial(i)) {
				System.out.println(i);
				count += i;
			}
		}

		System.out.println(count);
	}

	private static int factorial(int number) {
		int ret = 0;

		while (number > 0) {
			ret += fact[number % 10];
			number = number / 10;
		}

		return ret;
	}
}
